/************************************************
info: 整理一些公共常用的函数，期待以后的持续使用
data: 2022/02/10
author: hlp
************************************************/


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <unistd.h>
#include <sys/time.h>

//获取当前时间
static uint64_t getNowTime()
{
    struct timeval tval;
    uint64_t nowTime;

    gettimeofday(&tval, NULL);

    nowTime = tval.tv_sec * 1000L + tval.tv_usec / 1000L;
    return nowTime;
}

//checksum的一种计算方案，返回一个字节
unsigned char vps_checkxor(const char *strData,int len)  
{  
    char checksum = 0;  
    for (int i = 0;i < len;i++)  
    {  
        checksum = checksum ^ strData[i];  
    }  
    return (unsigned char)checksum;  
}

int main()
{
	uint64_t start_time = getNowTime();
	sleep(1);
	uint64_t end_time = getNowTime();
	//start_time is: [1644591019891] end_time is [1644591020901]  ms计算
	printf("start_time is: [%lu] end_time is [%lu] \n", start_time, end_time);
	return 0;
}

